use crate::model::environment::*;
use crate::repository::environment::EnvironmentRepository;

pub struct EnvironmentService {
    repository: EnvironmentRepository,
}

impl EnvironmentService {
    pub fn new(repository: EnvironmentRepository) -> Self {
        Self { repository }
    }

    pub async fn get_all_data(&self) -> Result<Vec<EnvironmentData>, sqlx::Error> {
        self.repository.find_all().await
    }

    pub async fn create_data(&self, data: CreateEnvironmentData) -> Result<i64, sqlx::Error> {
        self.repository.create(&data).await
    }
}